﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNET4Study
{
    class ClosureStudy
    {
        public static void Execute()
        {
            List<Action> actionList = new List<Action>();
            for (int i = 0; i < 10; i++)
            {
                actionList.Add(() =>
                {
                    Console.WriteLine(i);
                });
            }

            foreach (Action action in actionList)
            {
                action();
            }
        }

        public Func<int> T1()
        {
            var n = 999;
             return () =>
             {
                 Console.WriteLine(n);
                 return n;
             };
        }
    }
}
